import java.io.IOException;


public class ExRuntimeTask {
	
	private static final String executable ="/app/swift/production/FOFS/OFAC_Agent/FOFTEST";
	private static final String arguments = "-LISTNAME=FOFDB -REFERENCE=/app/swift/GLRD/OPERATIONS/current/LIST/SAN -LOGNAME=SAN_FOFT -MAINT=/app/swift/GLRD/OPERATIONS/logs -LISTDAYLIMIT=3000 -DATA=/app/swift/production/FOFS/OFAC_Agent -FMLON -CHECKDB -FILEIN=/app/swift/production/FOFS/OFAC_Agent/test.in -FILEOUT=/app/swift/production/FOFS/OFAC_Agent/test.out -REFRULES=/app/swift/production/FOFS/OFAC_Agent -RESOURCES=/app/swift/production/FOFS/OFAC_Agent/fkof.res";
		
	private static final String arguments1 = "-LISTNAME=FOFDB";
	private static final String arguments2 = "-REFERENCE=/app/swift/GLRD/OPERATIONS/progress/LIST/SAN"; 
	private static final String arguments3 = "-LOGNAME=SAN_FOFT -MAINT=/app/swift/GLRD/OPERATIONS/logs";
	private static final String arguments4 = "-LISTDAYLIMIT=3000";
	private static final String arguments5 = "-DATA=/app/swift/production/FOFS/OFAC_Agent";
	private static final String arguments6 = "-FMLON";
	private static final String arguments7 = "-CHECKDB";
	private static final String arguments8 = "-FILEIN=/app/swift/production/FOFS/OFAC_Agent/test.in";
	private static final String arguments9 = "-FILEOUT=/app/swift/production/FOFS/OFAC_Agent/test.out";
	private static final String arguments10 = "-REFRULES=/app/swift/production/FOFS/OFAC_Agent";
	private static final String arguments11 = "-RESOURCES=/app/swift/production/FOFS/OFAC_Agent/fkof.res";
	
	private static final String[] strArr ={executable,arguments};
	private static final String[] strArr1 ={executable,arguments1,arguments2,arguments3,arguments4,arguments5,arguments6,arguments7,arguments8,arguments9,arguments10,arguments11};
	
	
	
	
	
	public static void main(String[] args) {
		
		Process process = null;
		try {
			Runtime rt = Runtime.getRuntime();
			process = rt.exec(executable + " " + arguments);
			if(process != null){
				System.out.println(process.waitFor());
			}else {
				System.out.println("----------Process failed for exec() method -------------");
				System.out.println("----------trying with another method -------------");
				process = rt.exec(strArr);
				if(process != null){
					System.out.println(process.waitFor());
				}else {
					System.out.println("----------Process failed for exec() method -------------");
					System.out.println("----------trying with another method -------------");
					process = rt.exec(strArr1);
					if(process != null){
						System.out.println(process.waitFor());
					}else {
						System.out.println("----------Process failed for exec() method -------------");
					}
				}
				
			}

		} catch (IOException e) {
			e.printStackTrace();
			
		} catch (InterruptedException e) {
			e.printStackTrace();
		}finally{
			if(process != null){
				process.destroy();
				System.out.println("process destroyed successfully");
				
			}
		}

	}

}
